package com.zerui.manager.accessauthorization;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Objects;

/**
 * @Author wh
 * @create_time 2023-08-23 11:07
 */
@ApiModel("门禁授权")
@Getter
@ToString
@Accessors(chain = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AccessAuth {

	@ApiModelProperty("主键，无业务含义")
	@JsonFormat(shape = JsonFormat.Shape.STRING)
	private Long id;

	@ApiModelProperty("门禁组名称")
	private String name;

	@ApiModelProperty("日期类型 0:始终有效 1：日期范围")
	private Integer dateType;

	@ApiModelProperty("有效日期 - 开始")
	private LocalDate startDate;

	@ApiModelProperty("有效日期 - 结束")
	private LocalDate endDate;

	@ApiModelProperty("时间类型 0:全体有效 1：时间范围")
	private Integer timeType;

	@ApiModelProperty("有效时间 - 开始")
	private LocalTime startTime;

	@ApiModelProperty("有效时间 - 结束")
	private LocalTime endTime;

	@ApiModelProperty("备注")
	private String remark;

	@ApiModelProperty("创建时间")
	@JsonFormat(shape = JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
	private LocalDateTime createTime;

	public boolean equalsByTime(AccessAuth that) {
		if (this == that) {
			return true;
		}
		if (that == null || getClass() != that.getClass()) {
			return false;
		}
		return Objects.equals(dateType, that.dateType) &&
				Objects.equals(startDate, that.startDate) &&
				Objects.equals(endDate, that.endDate) &&
				Objects.equals(timeType, that.timeType) &&
				Objects.equals(startTime, that.startTime) &&
				Objects.equals(endTime, that.endTime);
	}
}
